// Copyright 2013 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package dfa.axis.v1_19.matchtables;

/**
 * Interface to aggregate unique DT file IDs and request data via SOAP API for match
 * table generation.  Each LookupObject class groups by 1 to many entity IDs.  Also
 * enumerates possible DT file field names.
 *
 * @author Moshe Kahan
 */
interface LookupObject {

  enum LookupField {
    AdId("Ad-ID"),
    AdvertiserId("Advertiser-ID"),
    BrowserId("Browser-ID"),
    BuyId("Buy-ID"),
    CityId("City-ID"),
    CountryId("Country-ID"),
    CreativeId("Creative-ID"),
    DesignatedMarketAreaId("DMA-ID"),
    MetEventId("Met-Event-ID"),
    OperatingSystemId("OS-ID"),
    OrderId("Order-ID"),
    PlacementId("Page-ID"),
    RenderingId("Rendering-ID"),
    SiteId("Site-ID"),
    StateId("State/Province"),
    Time("Time");

    LookupField(String fieldName) {
      this.fieldName = fieldName;
    }

    static LookupField getByFieldName(String fieldName) {
      for (LookupField field : values()) {
        if (field.getFieldName().equals(fieldName)) {
          return field;
        }
      }
      return null;
    }

    String getFieldName() {
      return fieldName;
    }

    private String fieldName;
  }

  /**
   * Called to parse the DT header row.
   *
   * @param index in DT file columns
   * @param header name of this DT file field/column
   */
  void addHeader(int index, String header) throws DataTransferFileException;

  /**
   * Called to clear the DT header information' usually because you're processing a new file.
   */
  void clearHeaders();

  /**
   * Called to parse the DT row.
   *
   * @param values array of tokenized Strings of DT file line
   */
  void addValues(String[] values) throws DataTransferFileException;

  /**
   * Called when parsing/aggregation is complete and match table generation should commence.
   *
   * @param outputPath location of match table to be generated.
   */
  void generateMatchTable(String outputPath) throws MatchTableFileException, DfaSoapException;
}
